package com.wwwarehouse.carddesk.fragment.mytabfragment;

import android.app.Dialog;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.wwwarehouse.carddesk.R;
import com.wwwarehouse.common.activity.base.BaseFragment;
import com.wwwarehouse.common.custom_widget.button.StateButton;
import com.wwwarehouse.common.eventbus_event.LogoutEvent;
import com.wwwarehouse.common.tools.DialogTools;

import de.greenrobot.event.EventBus;

/**
 * author ：minifly
 * date: 2017/10/21
 * time: 10:52
 * desc: 退出登录页面
 */
public class MyMessageQuitSystemFragment extends BaseFragment implements View.OnClickListener {

    private View v;
    private StateButton mDeskMyLogout;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        v = inflater.inflate(R.layout.fragment_desk_my_message_quitsystem, container, false);
        initView(v);
        return v;
    }

    public void initView(View view) {

        mDeskMyLogout = (StateButton) v.findViewById(R.id.desk_my_logout);
        mDeskMyLogout.setOnClickListener(this);
    }

    @Override
    public void setTitle() {
        if (peekFragment() instanceof MyMessageQuitSystemFragment) {
            mActivity.setTitle(getString(R.string.setting));
        }
    }

    @Override
    public void requestDatas() {

    }

    @Override
    public void onClick(View v) {
        int i = v.getId();
        if (i == R.id.desk_my_logout) {
            DialogTools.getInstance().showTCDialog(mActivity, "" + getString(R.string.logout),"" + getString(R.string.taskdesk_my_message_password_confirm), "" + getString(R.string.taskdesk_my_message_password_exit), "" + getString(R.string.taskdesk_my_message_password_no), new DialogTools.ConfirmListener() {
                @Override
                public void setConfirmListener(Dialog dialog, View view, String s) {
                    EventBus.getDefault().post(new LogoutEvent("logout"));
                }
            },null);
        }
    }
}
